Conversation
src/index.js
Outdated
| } | ||
|
|
||
| exports = module.exports = PeerId | ||
| exports = module.exports = withIs(PeerId, { className: 'PeerId', symbolName: '@libp2p/js-peer-id/PeerId' }) |
There was a problem hiding this comment.
There are a number of occasions in this file where we're accessing the non-wrapped PeerId class:
Line 157 in 6513a02
Line 162 in 6513a02
Line 166 in 6513a02
Line 170 in 6513a02
Line 199 in 6513a02
Line 231 in 6513a02
Line 282 in 6513a02
These all need to be changed otherwise they create PeerId objects that don't have the '@libp2p/js-peer-id/PeerId' symbol and so aren't considered to be instances of PeerId when used with PeerId.isPeerId.
There was a problem hiding this comment.
Yes! Thanks for noticing that.
I added PeerIdWithIs to all of them. However, I feel that there might be a better approach here. What do you think?
There was a problem hiding this comment.
Not really, js-cid uses _CID https://github.com/ipld/js-cid/blob/6d249ab8a3cc4000a1db0467f23046650453049a/src/index.js#L243
As `instance of` fails using different versions of a module, it was changed to use `class-is`. Needs: - [x] [js-peer-id#84](libp2p/js-peer-id#84) - [x] [interface-datastore#24](ipfs/interface-datastore#24) Fixes #1615
The
instance offails when using different versions of a module. This way, we end up with problems using this in other places, such as js-ipfs/core/ipns/publisher.js#L54.In the context of js-ipfs/issues/1615. This is not a problem now, as it is only occurring with
interface-datastorekey. However, it may occur in a future release of this module.